This invention relates to an automatic hook lock that can be operated either electrically or mechanically, and is particularly applicable to sliding gates. The shutting and opening of an entrance or passage can be achieved by use of sliding gates which might be operated either manually or by specific mechanical systems. In each of these cases, when the gate reaches the gate post it is necessary to provide for a means of fastening the same. In the case of manually actuated sliding gates, this is achieved by providing the gate with a hook lock mechanism to be operated by a key. The necessity for operation of the lock every time the gate has to be opened or shut renders the manual operation impractical and, indeed, impossible with gates operated by remote control. Actually, the application of locks on remote controlled sliding gates and, in particular, on those which are motorized, is achieved by the use of electrical equipment fixed on the gate post in correspondence with the locking mechanism. To function, the hook must necessarily be moved completely free, leaving the engagement and the successive disengagement of the same to the electrical equipment. The use of this type of hook does not, on the other hand, give the necessary security, as the hook can be easily operated by the introduction of a metal foil between the gate and the gate post. In conclusion, we assert that the adoption of a mechanical lock and separate electrical equipment does not give the required security and is more expensive, because it requires the use of two mechanisms.